package com.hj.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hj.system.entity.base.RoleEntity;
import com.hj.system.mapper.RoleMapper;
import com.hj.system.service.RoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author wxf
 * @since 2021-04-02
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, RoleEntity> implements RoleService {

    @Override
    public List<RoleEntity> list(Wrapper<RoleEntity> wrapper) {
        String roleName = wrapper.getEntity().getRoleName();
        if (StringUtils.isNotBlank(roleName)) {
            wrapper.getEntity().setRoleName(null);
            QueryWrapper queryWrapper = (QueryWrapper) wrapper;
            queryWrapper.like("role_name", roleName);
        }
        return super.list(wrapper);
    }
}
